package com.guosifan.controller;

import com.guosifan.entity.Admin;
import com.guosifan.entity.User;
import com.guosifan.repository.AdminRepository;
import com.guosifan.repository.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/account")
public class AccountController {

    @Autowired
    private AdminRepository adminRepository;

    @Autowired
    private UserRepository userRepository;

    @GetMapping("/login/{username}/{password}/{type}")
    public Object login(@PathVariable("username")String username,@PathVariable("password")String password,@PathVariable("type")String type){
        Object obj="";
        if("admin".equals(type)){
            obj = adminRepository.selectByAdmin(new Admin(username, password));
        }
        if("user".equals(type)){
            obj =userRepository.selectByUser(new User(username,password));
        }
        System.out.println(obj);
     return obj;
    }



}
